package com.tiger.weixin;

import com.alibaba.fastjson2.JSON;
import com.tiger.weixin.api.WeixinApi;
import com.tiger.weixin.dto.AccessToken;
import com.tiger.weixin.dto.WxMsgTask;
import com.tiger.weixin.token.AccessTokenContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: spzhang
 * @Date: Created in 15:33 2023/2/20
 * @Description:
 * @Version:
 */
@Slf4j
@RestController
public class ZspTestController {
    @Autowired
    private AccessTokenContext accessTokenContext;
    @Autowired
    private WeixinApi weixinApi;

    @RequestMapping("/zsp/test")
    public AccessToken test() {
        AccessToken accessToken = accessTokenContext.getAccessTokenSerial();
        log.info(JSON.toJSONString(accessToken));
        return accessToken;
    }

    @PutMapping("/zsp/send")
    public boolean send(@RequestBody WxMsgTask wxMsgTask) {
        return weixinApi.sendMsg(wxMsgTask);
    }


}
